/*
 * HourTimer.h
 *
 *  Created on: 2020年1月11日
 *      Author: terry
 */

#ifndef HOURTIMER_H_
#define HOURTIMER_H_

#include "BasicType.h"
#include <functional>
#include "TThread.h"
#include "TCriticalSection.h"
#include "TEvent.h"


class HourTimer : public comn::Thread
{
public:
	typedef std::function< void (int64_t time, int weekday, int hour) >		TimerHandler;

	static const int DEF_INTERVAL;

public:
	HourTimer();
	virtual ~HourTimer();

	void setHandler(TimerHandler handler);

	bool open();
	void close();
	bool isOpen();

	void resetTime();


protected:
	virtual int run();
	virtual void doStop();

	int64_t getClock();

	int checkTime();

	void fireHour(int64_t clock, int weekday, int hour);

protected:
	TimerHandler	m_handler;
	comn::Event	m_event;



};

#endif /* HOURTIMER_H_ */
